package com.kly.sc.api.application.controller.product.request;

import com.fqgj.common.api.ParamsObject;
import com.kly.enums.ProductCategory;
import com.kly.sc.api.infras.exception.ApplicationException;
import com.kly.user.enums.UserOpActionEnum;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 查询产品
 * @author linqu
 */
public class ProductRequest extends ParamsObject {

    /**
     * 产品类目：1、会员产品，2、会话产品，3、私密相册、4、私密视频
     */
    private Integer productCategory;

    /**
     * 1-会员购买 2-弹窗
     */
    private Integer from;

    public Integer getProductCategory() {
        return productCategory;
    }

    public void setProductCategory(Integer productCategory) {
        this.productCategory = productCategory;
    }

    public Integer getFrom() {
        return from;
    }

    public void setFrom(Integer from) {
        this.from = from;
    }

    @Override
    public void validate() {
        if (Objects.isNull(this.productCategory) || Objects.equals(ProductCategory.fromType(productCategory), ProductCategory.ISNULL)) {
            throw new ApplicationException("The request [productCategory] should not be empty or invalid");
        }
    }
}
